<template>
  <view class="login-wrapper">
    <image
      class="bg"
      src="@/static/auth/auth.png"
      mode="widthFix"
      style="margin-top: 300rpx"></image>
    <view class="goback" @click="backPage">
      <image
        style="width: 60rpx; height: 60rpx"
        src="@/static/auth/icon-login12-goback.png"></image>
    </view>
    <view class="header">
      <view>登录授权</view>
      <view class="header-title">授权登录PC端</view>
    </view>
    <view class="content">
      <!--#ifdef MP-WEIXIN -->
      <button class="handle" style="height: 100rpx" @click="uniAuth">
        <image
          style="width: 50rpx; height: 50rpx; margin-right: 10rpx"
          src="@/static/auth/icon-login12-weixin.png"></image>
        <text>确认登录</text>
      </button>
      <!--#endif-->
      <!-- <view @click="toPage('/pages/login')">账号密码登录</view> -->
    </view>
  </view>
</template>
<script setup>
import { computed, getCurrentInstance, reactive, ref } from "vue";
import {
  onLoad,
  onShow,
  onPullDownRefresh,
  onReachBottom,
} from "@dcloudio/uni-app";
import request from "@/lib/request.js";
import { showLoading, closeLoading, handleRes } from "@/lib/common.js";
import useWxStore from "@/store/module/wx.js";
const wxStore = useWxStore();
const uuid = ref("");
onLoad((options) => {
	
  const scene = decodeURIComponent(options.scene);
  wxStore.doWxAuth();
  console.log(scene);
  uuid.value = scene;
});
// 函数
function uniAuth() {
  // 微信小程序登录
  showLoading("登录中");
  // #ifdef MP-WEIXIN
  request({
    url: "/pms/scanLogin",
    method: "POST",
    data: {
      uuid: uuid.value,
    },
  }).then((ans) => {
    console.log(ans);
    closeLoading();
    uni.switchTab({
      url: "/custom/edu/pages/index/index",
    });
  });
  // #endif
}
function backPage() {
  uni.switchTab({
    url: "/custom/edu/pages/index/index",
  });
}
// function toPage(val) {
// 	uni.navigateTo({
// 		url: val,
// 	});
// }
</script>
<style>
.login-wrapper {
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.bg {
  position: absolute;
  width: 100%;
  height: 100%;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  z-index: 1;
  object-fit: cover;
}

.goback {
  width: 90%;
  display: flex;
  padding-top: 80rpx;
  padding-bottom: 40rpx;
  justify-content: flex-start;
  z-index: 11;
}

.content {
  width: 85%;
  margin-top: auto;
  margin-bottom: 20%;
  z-index: 11;
  text-align: center;
  font-size: 30rpx;
  color: rgba(0, 0, 0, 1);
}

.header {
  width: 85%;
  margin-top: 60rpx;
  font-size: 45rpx;
  font-weight: 600;
  color: rgba(0, 0, 0, 0.9);
  z-index: 11;
}

.header-title {
  font-size: 30rpx;
  color: rgba(0, 0, 0, 0.7);
  margin-top: 20rpx;
  font-weight: bold;
}

.handle {
  background-color: #5be286;
  border-radius: 20rpx;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #fff;
  font-size: 35rpx;
  padding: 20rpx 30rpx;
  margin-bottom: 40rpx;
}
</style>
